package com.cskaoyan.catmall.service.Impl;

import com.cskaoyan.catmall.dao.MarketAdMapper;
import com.cskaoyan.catmall.dao.MarketStorageMapper;
import com.cskaoyan.catmall.dao.PromotionMapper;
import com.cskaoyan.catmall.model.bo.PromotionAdBo;
import com.cskaoyan.catmall.model.pojo.MarketAd;
import com.cskaoyan.catmall.model.vo.ItemOfAdListVo;
import com.cskaoyan.catmall.model.vo.PromotionBaseVo;
import com.cskaoyan.catmall.service.PromotionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 创建日期: 2022-01-07-11-51
 * author : LL
 * description: 推广相关方法
 */

@Service
public class PromotionServiceImpl implements PromotionService {
    @Autowired
    PromotionMapper promotionMapper;
    @Autowired
    MarketStorageMapper storageMapper;
    @Autowired
    MarketAdMapper adMapper;


    @Override
    public PromotionBaseVo<ItemOfAdListVo> getPromotionAds(PromotionAdBo promotionAd) {
        List<ItemOfAdListVo> promotionAdVoList = promotionMapper.getPromotionAds(promotionAd);
        PromotionBaseVo<ItemOfAdListVo> promotionAdVo = new PromotionBaseVo();
        promotionAdVo.setList(promotionAdVoList);
        return promotionAdVo;
    }


//
//    @Override
//    public List<ItemOfPromotionCategoryVo> getPromotionCategory(BaseParamBo baseParam) {
//        List<ItemOfPromotionCategoryVo> promotionCategoryVos = promotionMapper.getPromotionCategory(baseParam);
//        for (ItemOfPromotionCategoryVo promotionCategoryVo : promotionCategoryVos) {
//            Integer id = promotionCategoryVo.getId();
//            List<ChildrenOfCategoryVo> childrenOfCategoryVos = promotionMapper.getChildrenOfCategory(id);
//            promotionCategoryVo.setChildren(childrenOfCategoryVos);
//        }
//        return promotionCategoryVos;
//    }

//    @Override
//    public List<PromotionGoodsListVo> getPromotionGoods(BaseParamBo baseParam) {
//        List<PromotionGoodsListVo> promotionGoodsListVos = null;
//        try {
//            promotionGoodsListVos= promotionMapper.getPromotionGoods(baseParam);
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//        return promotionGoodsListVos;
//
//    }



//    @Override
//    public void storeImage(MarketStorage marketStorage) {
//        int code = storageMapper.insertSelective(marketStorage);
//    }

    @Override
    public void insertAd(MarketAd marketAd) {
        marketAd.setAddTime(new Date());
        marketAd.setUpdateTime(new Date());
        adMapper.insertSelective(marketAd);
    }

    @Override
    public void deleteAd(MarketAd marketAd) {
        promotionMapper.deleteAd(marketAd);
        return;
    }

    @Override
    public void updateAd(MarketAd marketAd) {
        marketAd.setUpdateTime(new Date());
        adMapper.updateByPrimaryKeySelective(marketAd);
        return;
    }



}